class Solution {
public:
    bool findNumberIn2DArray(vector<vector<int>>& matrix, int target) 
    {
        if(matrix.size()==0||matrix[0].size()==0)
        return false;
        int maxi=matrix.size()-1;
        int maxj=matrix[0].size()-1;
        size_t i=0;
        size_t j=maxj; 
        while(i<=maxi&&j<=maxj)
        {
            if(matrix[i][j]<target)
            {
                i++;
            }
            else if(matrix[i][j]>target)
            {
                j--;
            }
            else
            {
                return true;
            }
        }
        return false;

    }
};